How To Set Up HSM Delivery Dashboard
4 minute read Advanced
Problem: How to find the number of contacts who did not get the business initiated message due to frequency capping regulations imposed by Meta on Marketing HSMs.
Context: Meta recently introduced something called as Frequency capping. Explaining in a simple manner, it noticed that users get a lot of Marketing messages from businesses, and to limit SPAM daily, it restricts how many Marketing messages a user can get during a rolling period of X days.
To prevent misuse and gaming the system, they haven’t told us how many messages are allowed in how many days. You can read more about this in their own words here.
Solution: To understand contacts, templates, and campaigns affected (based on dates the broadcast was initaited) by having information of errors that were encountered visialized on a lookerstudio dashboard. This will reduce the effort in repeteadly quering this infomration from the database for every braodcast made, and to make this information easily accessible to the program / operations team to work with.
SELECT
JSON_EXTRACT_SCALAR(m.errors, '$.app') AS app,
JSON_EXTRACT_SCALAR(m.errors, '$.payload.destination') AS destination,
JSON_EXTRACT_SCALAR(m.errors, '$.payload.type') AS type,
JSON_EXTRACT_SCALAR(m.errors, '$.payload.payload.reason') AS reason,
DATE(m.sent_at) AS sent_on,
m.flow_name AS flow_name,
m.template_uuid AS template_id,
m.body AS message,
m.media_url,
m.is_hsm,
m.contact_name,
m.contact_phone
FROM `project-name.bot-number.messages` AS m
WHERE m.bsp_status = "error"
GROUP BY
app, destination, type, reason, sent_on, flow_name, template_id, message, m.media_url, m.is_hsm, m.contact_name, m.contact_phone;
- For this query to work for your organization, reaplce the 'projet-name' with the name of your Google Cloud project within which the Big Qusery instance is set up.
- Replace the 'bot-number' with the chatbot number being used, pre-fixed with the country code.
How to set this up
1. Sign into Bigquery using the appropriate email account and select the options to run a query.
- Navigate to bigquery. Expand the phone number (aka dataset) and select
Contacts
table
- Click on the “Query’ button to create an empty query
- You will get an empty query which looks like this
-
Copy paste the query above into the query window. Replace the phrase “dataset” with the values from the empty query. Copy everything (projectname.dataset) from the ‘ symbol till the .(dot) before contacts and paste it in the 2 places it says “dataset”. Delete the empty query so that only what you pasted is visible on the screen.
-
Hit the ‘Run’ button. You will see Query Results coming once the query has run
- Click on Save and select “Save View”
- In the popup you see, select the correct values. Name the table “error_hsm_and_media”
- You will now see a new table/view popping up in the list of tables in the left of the screen
Now that the data is formatted as you need it, lets move to Part 2
2. Setting up the visualization.
-
Sign in to your Look Studio space using your work google account associated with BigQuery
-
Open this link - https://lookerstudio.google.com/u/0/reporting/859eb34f-2f9a-410c-8baa-dacf28af6c33/page/oBhGF/preview in your browser
-
In the top right corner, you will see 2 buttons next to your user profile icon
-
Click on Use my own data
-
Navigate the options, to select your project. Then the data set, and then finally the view we just created. Your dashboard is ready!
-
Finish off the steps by clicking "Edit and Share"
-
This will lead you to the same preview link as shared above.
-
Navigate to the lookerstudio homepage by clicking the top left "Lookerstudio" icon, next to the "HSM and Media Errors" name of the dashboard
- See that a new copy of the dashboard has been created.
- Go to this copy of the dashboard, go to edit and change the name to include your org's name for future reference.
Editing and modifying further
- To see a list of users and numbers or any other such details, select Edit.
- Then Select Add a chart. Select a table.
- Drag and drop the fields contact_name and contact_phone under “Dimension”.
- You can now extract all the affected users when apply the relevant filters by Hovering on the top right corner of the chart,
- clicking on “more”, then Export and selecting the format you prefer!